package hello;


import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Sprite {

    //atributos privados
    protected int x;
    protected int y;
    protected int width;
    protected int height;
    protected int incX;
    protected int incY;

	private boolean cambio=false;


   public  Sprite(int x, int y, int width, int height){
        this.x=x;
        this.y=y;
        this.width=width;
        this.height=height;
        incX=3;
        incY=3;
    }
    //metodo constructor

	
	 public void mover ( int numero, int screenH, int screenW){
        if(numero == 1){
            if(y<=0)
                  y = 0;
               else
                  y -= 10;
         }
         if(numero == 2){
             if(y+20>=screenH)
                  y = screenH-20;
               else
             y += 10;
        }
         if(numero == 3){
             if(x<=0)
                  x = 0;
               else
             x -=10;

        }
         if(numero == 4){
             if(x+20>=screenW)
                  x = screenW-20;
               else
             x+= 10;

        }
    }
	public boolean cambio(){
		return cambio;
	}
    //metodo que actualiza la posición del sprite
    public void compute(int screenW, int screenH){
		
        if(x <= 0){
		incX=3;		
		cambio=false;
		}
        if (x+width >= screenW){
		cambio=true;
		incX=-3;
		}
        x+=incX;
    }
	public void draw2(Graphics g) {
        g.setColor(0xb20000);
        g.fillArc(x,y, width, height,300, 300);
	}
	public void draw3(Graphics g) {
        g.setColor(0x808080);
        g.fillArc(x,y, width, height,210, 300);
	}
	public void draw1(Graphics g) {
        g.setColor(0x808080);
        g.fillArc(x,y, width, height,120, 300);
	}
	private Image imagen;
    public void draw4(Graphics g){

        
        g.setColor(0xb20000);
        g.fillArc(x,y, width, height,30, 300);
        g.drawImage(imagen, 100,100, Graphics.HCENTER | Graphics.TOP);

            }
}
